package com.woniu.microprojectserver.spacemag.service.impl;

import com.woniu.microcommonsserver.entity.SpaceInfoEntity;
import com.woniu.microprojectserver.buildmag.mapper.BuildMapper;
import com.woniu.microprojectserver.spacemag.mapper.SpaceMapper;
import com.woniu.microprojectserver.spacemag.service.ISpaceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：pengchufeng
 * @date ：Created in 2021/2/1
 * @description：空间service接口实现
 */
@Transactional(readOnly = true)
@Service
public class SpaceServiceImpl implements ISpaceService {

    @Resource
    private SpaceMapper spaceMapper;

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public List<SpaceInfoEntity> findAll() {
        return spaceMapper.findAll();
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public SpaceInfoEntity findById(String id) {
        return spaceMapper.findById(id);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public List<SpaceInfoEntity> findByBId(String id) {
        return spaceMapper.findByBId(id);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public List<SpaceInfoEntity> findByHId(String id) {
        return spaceMapper.findByHId(id);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean add(SpaceInfoEntity spaceInfoEntity) {
        spaceMapper.add(spaceInfoEntity);
        return true;
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean update(SpaceInfoEntity spaceInfoEntity) {
        spaceMapper.update(spaceInfoEntity);
        return true;
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean delete(String id) {
        spaceMapper.delete(id);
        return true;
    }
}
